package util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author TZL
 * @date 2020/8/13
 */
public class ConnUtil {

   static String host="192.168.125.128";
   static int port=5672;
   static String virtualHost="admin";
   static String username="admin";
   static String password="admin";

   public static Connection getConn(){
       //创建Connection工厂
       ConnectionFactory factory=new ConnectionFactory();
       factory.setHost(host);
       factory.setPort(port);
       factory.setVirtualHost(virtualHost);
       factory.setUsername(username);
       factory.setPassword(password);

       Connection conn = null;
       try {
           conn = factory.newConnection();
       } catch (IOException | TimeoutException e) {
           e.printStackTrace();
       }

       return conn;
   }


}
